home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7259 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  74 lines

  1. Path: titan.fullerton.edu!etezadi
  2. From: etezadi@titan.fullerton.edu (Syrous Etezadi Amoli)
  3. Newsgroups: comp.lang.c++
  4. Subject: Help to solve the link list problem
  5. Date: 22 Feb 1996 10:18:02 GMT
  6. Organization: California State University at Fullerton
  7. Message-ID: <4ghfsq$cpf@nuke.csu.net>
  8. NNTP-Posting-Host: ecs.fullerton.edu
  9.  
  10. Hi
  11.  
  12.  
  13. Would you tell me what is wrong with the following code which implements
  14. a linked list with the use of TListImp of BC++ 4.5 ?
  15.  
  16. Thanks
  17.  
  18. #include <classlib\listimp.h>
  19. #include <iostream.h>
  20. #include <String.h>
  21.  
  22. void main()
  23. {
  24.  
  25.  
  26. class CIndexListElement : public: string{
  27.  private:
  28.   string subject;
  29.   long start;
  30.   long end;
  31.  public:
  32.  
  33.   DWORD GetStart(void) {return start;};
  34.   DWORD GetEnd(void) { return end;};
  35.   string GetSubject(void) {return subject;};
  36.   void SetStart(DWORD x) {start = x;};
  37.   void SetEnd(DWORD x) {end = x;};
  38.   void SetSubject(string s) { subject = s;};
  39.   private:
  40.  
  41.  
  42. };
  43. TListImp<CIndexListElement> m_SubjectList;
  44.  
  45. CIndexListElement *new_entry=  new CIndexListElement;
  46. new_entry->SetSubject("1st subject");
  47. new_entry->SetEnd(1);
  48. new_entry->SetStart(1);
  49. m_SubjectList.Add(new_entry);
  50. new_entry->SetSubject("2ND subject");
  51. new_entry->SetEnd(2);
  52. new_entry->SetStart(2);
  53. m_SubjectList.Add(new_entry);
  54. new_entry->SetSubject("3RD subject");
  55. new_entry->SetEnd(3);
  56. new_entry->SetStart(3);
  57. m_SubjectList.Add(new_entry);
  58.  
  59. TListIteratorImp<cIndexListElement> next(m_SubjectList);
  60. cout << "\n The stored items are:\n" << next++;
  61.  
  62. while (next)
  63.   cout << ", " << next++;
  64. cout << endl;
  65. }
  66.  
  67.  
  68. --
  69.   
  70.  
  71. --------------
  72. Syrous Etezadi Amoli (SEA)
  73. etezadi@titan.fullerton.edu
  74.